home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_11_09 / 1109114a < prev    next >
Text File  |  1993-07-11  |  695b  |  31 lines

  1. /* array6.c: Ragged arrays */
  2.  
  3. #include <stdio.h>
  4. #include <string.h>
  5.  
  6. main()
  7. {
  8.     char *strings[] = {"now","is","the","time"};
  9.     size_t n = sizeof strings / sizeof strings[0];
  10.     int i;
  11.  
  12.     /* Print from ragged array */
  13.     for (i = 0; i < n; ++i)
  14.         printf("String %d == \"%s\","
  15.                "\tsize == %d,"
  16.                "\tlength == %d\n",
  17.                i,strings[i],
  18.                sizeof strings[i],
  19.                strlen(strings[i]));
  20.  
  21.     return 0;
  22. }
  23.  
  24. /* Output
  25. String 0 == "now",  size == 2,  length == 3
  26. String 1 == "is",   size == 2,  length == 2
  27. String 2 == "the",  size == 2,  length == 3
  28. String 3 == "time", size == 2,  length == 4
  29. */
  30.  
  31.